-cycles = Cycle.where(:program_id => program.id).order('start_at DESC')

-content_for :widget_title do
  %i.grcicon-audit-white
  Audit Cycles
  %span=cycles.count

-content_for :widget_help, 'program_cycles'

-content_for :widget_id, "audit_cycles_widget"

%ul.tree-structure.simple
  -cycles.each do |cycle|
    %li
      .item-main
        .item-title
          .row-fluid
            .span9
              %a.custom-popover-trigger{:href => flow_cycle_path(cycle), :'data-popover-href' => tooltip_flow_cycle_path(cycle), :'data-popover-trigger' => 'sticky-hover'}
                .oneline
                  %span.title
                    -if cycle.complete
                      %span.completed
                        =cycle.title
                    -else
                      =cycle.title
                  %span.additional-info
                    -if cycle.complete
                      %span.completed
                        completed
                    -else
                      -if cycle.start_at == Time.zone.now.to_date
                        today
                      -elsif cycle.start_at < Time.zone.now.to_date
                        #{days_ago_in_words cycle.start_at} ago
                      -else
                        starting in: #{days_ago_in_words cycle.start_at}
                      -if cycle.end_at
                        &nbsp;&nbsp;&nbsp;
                        ends on: #{cycle.end_at.strftime("%m/%d/%y")}
            .span2
              .objects-count
